module executor.friend.SetContactAliasName;

import msgtrans;
import message.Constants;
import message.MsgDefine;
import google.protobuf;
import hunt.logging;
import std.array;
import std.conv : to;
import hunt.util.Serialize;
import client.GateServerClient;
import client.MsgServerClient;
import service.ContactsService;
import service.ApplyService;
import service.FriendService;


@TransportServer(LogicServerName)
class SetContactAliasName : AbstractExecutor!(SetContactAliasName) {

  //设置好友昵称接口
 @MessageId(MESSAGE.CMD_SET_CONTACTS_ALIAS_NAME_REQ)
 void setContactAliasName(TransportContext ctx, MessageBuffer buffer)
 {
   auto req = new SetContactAliasNameREQ();
   buffer.data.fromProtobuf!SetContactAliasNameREQ(req);

   auto res = new SetContactAliasNameRES();
   res.chatId = req.chatId;
   res.userId = req.userId;
   res.succeeded = false;
   if(FriendService.setContactAliasName(req.userId, req.chatId, req.aliasName))
   {
      res.succeeded = true;
   }
   ctx.session.send(new MessageBuffer(MESSAGE.CMD_SET_CONTACTS_ALIAS_NAME_RES,res.toProtobuf.array));
 }

}

